let defaultCity = '上海'
try {
  if (localStorage.city) {
    defaultCity = localStorage.city
  }
} catch (e) {}


export const state = () => ({
  city: defaultCity
})

export const mutations = {
  setCity (state,city) {
    state.city = city
    try {
      localStorage.city = city
    } catch (e) {}
  }
}



export const actions = {
  // nuxtServerInit is called by Nuxt.js before server-rendering every page
  async nuxtServerInit({commit}, { req }) {
      commit('setCity',defaultCity)
  }
}
